#include <stdio.h>

int arr[1001][1001];


int main()
{
	int n = 0;
	scanf_s("%d", &n);
	int i = 1, j = 1;
	int k = 1;
	arr[1][1] = k;
	int pos = 1;
	for (k = 2; k <= n * n; k++)
	{
		if (i == 1 && j < n && pos == 1)
		{
			arr[i][++j] = k;
			pos = -1;
		}
		else if (j == 1 && i < n && pos == -1)
		{
			arr[++i][j] = k;
			pos = 1;
		}
		else if (i == n && j < n && pos == -1)
		{
			arr[i][++j] = k;
			pos = 1;
		}
		else if (j == n && i < n && pos == 1)
		{
			arr[++i][j] = k;
			pos = -1;
		}
		else if (pos == 1)
		{
			arr[--i][++j] = k;
		}
		else if (pos == -1)
		{
			arr[++i][--j] = k;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			printf("%d ", arr[i][j]);
		}
		printf("\n");
	}
	return 0;
}